def data_response(user=None, token=None, data=None, request=None):
    if user:
        return {
            'code': 0,
            'data': {
                'id': user.id,
                'username': user.username,
                'token': token
            }
        }
    else:
        return {
            'code': 0,
            'data': data
        }


def message_response(code=None, message=None):
    if code == 0:
        return {
            "code": code,
            "message": message
        }
    return {
        "code": 1,
        "message": message
    }
